package com.farm.command;

class AdjustSpeedCommand implements Command {
    private AgriculturalMachineReceiver machine;
    private int speed;
    private int previousSpeed;

    public AdjustSpeedCommand(AgriculturalMachineReceiver machine, int speed) {
        this.machine = machine;
        this.speed = speed;
        this.previousSpeed = 0; // 默认值
    }

    @Override
    public void execute() {
        // 假设我们记录了之前的速度
        previousSpeed = (int)(Math.random() * 10); // 模拟获取之前的速度
        machine.adjustSpeed(speed);
    }

    @Override
    public void undo() {
        machine.adjustSpeed(previousSpeed);
    }
}

